#pragma once

#include "Component.h"
#include "GameTimer.h"
#include "DirectInput.h"

class D3DApp
{
public:
	D3DApp();
	D3DApp(HINSTANCE hInstance, std::string winCaption,
		D3DDEVTYPE devType, DWORD requestVP);
	virtual ~D3DApp();

	HWND GetMainWindow(){ return mhMainWindow; }
	HINSTANCE GetAppInstance(){ return mhAppInstance; }
	bool GetDeviceLost();

	virtual LRESULT MsgProc(UINT msg, WPARAM wParam, LPARAM lParam);
	virtual int Run();

protected:
	virtual void InitMainWindow();
	virtual void InitDirect3D();
	virtual bool CheckDeviceCaps(){ return true; }
	virtual void OnResetDevice();
	virtual void OnLostDevice();
	virtual void Update(float dt);
	virtual void Draw();

	D3DPRESENT_PARAMETERS mD3Dpp;

private:

	void ResetDevice();
	IDirect3D9* mD3DObject;

	bool mAppPaused;
	HWND mhMainWindow;
	HINSTANCE mhAppInstance;
	std::string mMainWindowCaption;

	D3DDEVTYPE mDevType;
	DWORD mRequestedVP;

	ID3DXSprite* mSpriteBatch;

	D3DXVECTOR3 pos;
	D3DXVECTOR3 target;
	D3DXMATRIX view;
	D3DXMATRIX proj;
};

